<?php

namespace Dreamcat\PropertyAnalysis\Utils;

use Dreamcat\PropertyAnalysis\Pojo\BuildinType;

/**
 * 内置类型相关辅助信息
 * @author vijay
 */
class BuildinTypeHelper
{
    /** @var callable[] 检查函数 */
    public const CHECK_FUNC = [
        BuildinType::STRING => "is_string",
        BuildinType::ARRAY => "is_array",
        BuildinType::INT => "is_int",
        BuildinType::FLOAT => "is_float",
        BuildinType::BOOL => "is_bool",
        BuildinType::CALLABLE => "is_callable",
        BuildinType::MIXED => [MixedFunc::class, "checkMixed"],
    ];

    /** @var array 默认值 */
    public const DEFAULT_VALUE = [
        BuildinType::STRING => "",
        BuildinType::ARRAY => [],
        BuildinType::INT => 0,
        BuildinType::FLOAT => 0,
        BuildinType::BOOL => false,
        BuildinType::MIXED => null,
    ];

    /** @var array 格式化函数 */
    public const VALUE_FORMAT = [
        BuildinType::STRING => "strval",
        BuildinType::INT => "intval",
        BuildinType::FLOAT => "floatval",
        BuildinType::BOOL => "boolval",
    ];

    /** @var bool[] 是否标量 */
    public const IS_SCALAR = [
        BuildinType::STRING => true,
        BuildinType::ARRAY => false,
        BuildinType::INT => true,
        BuildinType::FLOAT => true,
        BuildinType::BOOL => true,
        BuildinType::CALLABLE => false,
        BuildinType::MIXED => false,
    ];
}

# end of file
